<template>
	<view class="page">
		<nav-bar :title="detail.title || detail.msgType?.label" leftArrow />
		<view class="time">{{ detail.createTimeStr }}</view>
		<view class="content" v-html="detail.content || '内容'"></view>
	</view>
</template>

<script setup>
	import {
		ref,
		onUnmounted
	} from 'vue';

	import {
		apiBizMessageMyRead,
	} from '@/api/message';

	const path = defineProps({
		id: String,
	});

	const detail = ref({})

	const getDetail = () => {
		detail.value = uni.getStorageSync('message-detail') || {};;

		if (detail.value.readFlag === '0') {
			apiBizMessageMyRead({
				value: path.id,
			});
		}
	}

	getDetail()

	onUnmounted(() => {
		uni.setStorageSync('message-detail', {});
	})
</script>

<style lang="scss" scoped>
	.page {
		background-color: #fff;
		font-size: 28rpx;

		.time {
			padding-top: 20rpx;
			text-align: center;
		}

		.content {
			padding: 30rpx;
			text-indent: 24rpx;

			div,
			p {
				text-indent: 24rpx;
			}

			line-height: 1.8;
		}
	}
</style>